// 从cookie缓存操作Token
import Cookies from "js-cookie";
import { TOKEN_KEY } from "@/enums/cacheEnum";

// 获取cookie的值
export function getToken() {
  return Cookies.get(TOKEN_KEY);
}

// 设置缓存cookie的值
export function setToken(token: string, expiration: number) {
  var millisecond = new Date().getTime();
  var expiresTime = new Date(millisecond + expiration);
  return Cookies.set(TOKEN_KEY, token, {
    expires: expiresTime,
  });
}

export function removeToken() {
  return Cookies.remove(TOKEN_KEY);
}
